/**
 * 
 */
package com.dangdang.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.smartstruts.action.Action;
import org.smartstruts.action.ActionForm;

import com.dangdang.domain.Book;
import com.dangdang.service.BookService;
import com.dangdang.service.ProductCategoryService;
import com.dangdang.service.ProductService;
import com.dangdang.service.ServiceFactory;
import com.dangdang.util.Constants;
import com.dangdang.util.FormUtils;

/**
 * 管理员综合控制类
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-1-18
 */
public class ManagementAction extends Action {

	ProductService productService = ServiceFactory.getProductService();
	BookService bookService = ServiceFactory.getBookService();
	ProductCategoryService productCategoryService = ServiceFactory
			.getProductCategoryService();

	/**
	 * 通用请求
	 */
	@Override
	public String execute(ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		return Constants.FORWARD_SUCCESS;
	}

	/**
	 * 添加商品执行方法
	 * 
	 * @param form
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public String addProduct(ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		request.setCharacterEncoding("utf-8");
		Book book = new Book();
		FormUtils.populate(book, request);
		bookService.addBook(book);
		return Constants.FORWARD_SUCCESS;
	}
}
